package com.suliao.web.controller;

import cn.hutool.core.util.URLUtil;
import com.suliao.common.annotation.LoginCheck;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author ：M1nG
 * @date ：Created in 2020/12/5 14:39
 * @description：
 * @version: 1.0
 */
@Controller
@RequestMapping("/")
@Slf4j
public class IndexController {

    @LoginCheck
    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @PostMapping("/error/{page}/{msg}")
    public String error(Model model, @PathVariable("page") Integer page, @PathVariable("msg") String msg) {
        model.addAttribute("page", page);
        model.addAttribute("msg", URLUtil.decode(msg));
        return "error";
    }

}
